package com.zm.zmgz.utils;

import javax.swing.text.rtf.RTFEditorKit;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * Created with IntelliJ IDEA.
 *
 * @Auther: cjw
 * @Date: 2020/04/01/9:04
 * @Description: 自用集合相关工具方法
 */
public class CollectionUtilszm {

    /***
    * @Description: list集合类型假分页
    * @Param: list集合类型,当前页,每页显示条数
    * @return: list类型集合
    * @Author: cjw
    * @Date: 2020-04-01 09:05:48
    */
    public static List getListPagination(List list,int page,int limit) {
        if(page == 0 && limit == 0) {
            return list;
        }
        int start = (page - 1) * limit; // 复制开始下标
        int end = start + limit - 1; // 复制结束下标
        List list1 = new ArrayList();
        if(list.size() < start + 1){
            return null;
        }
        for (int i = start; i <= end; i++) {
            if (list.size() < i+1) {
                break;
            } else {
                list1.add(list.get(i));
            }
        }
        return list1;
    }


}
